home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / c_toolbx.arc / TESTIO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1988-03-30  |  2.3 KB  |  95 lines

  1. /* testio.c - test viewio.c */
  2. #include "stdio.h"
  3. #include "cminor.h"
  4. #include "viewparm.h"
  5.  
  6. extern    FILE  *fp  ;
  7. extern long filesize  ;
  8. long ftell()  ;
  9. long where_now()  ;
  10.  
  11. main()
  12.   {
  13.      long pos ;
  14.      int c , i ;
  15.      char fn[65] ;
  16.  
  17.      printf("\n testing I/O module\n") ;
  18.  
  19.      printf("\n file name:") ;
  20.      scanf("%s",fn) ;
  21.      printf("\n open_file = %d ",open_file(fn) ) ;
  22.      printf("\n fp = %x ",fp) ;
  23.  
  24.      printf("\n\n calling set_filesize") ;
  25.      filesize = -1L ;
  26.      set_filesize(ASC_MODE) ;
  27.      printf("\n filesize = %1d  \n",filesize)  ;
  28.  
  29.      pos = 3  ;
  30.      printf("\n move)to %1d",pos) ;
  31.      mone_to(pos)  ;
  32.      printf("\n where_now = %1d next char is %d  ftell = %1d\n",
  33.      where_now() , get_next_char() , ftell(fp) ) ;
  34.      pos = 1  ;
  35.      move_to(pos) ;
  36.      printf("\n move_to %1d",pos) ;
  37.      printf("\n where_now = 1d  next char is %d  ftell = %1d\n",
  38.      where_now(), get_next_char(), ftell(fp) ) ;
  39.  
  40.  
  41.      scanf("%c%c",&c,&c) ;              /* pause here  */
  42.  
  43.  
  44.      /* test get_next_char  */
  45.      move_to(0L) ;  /* start at beginning of file */
  46.      printf("\n test get next char - sequintial reads  \n ") ;
  47.      c    = get_next_char()  ;
  48.      i = 0 ;
  49.      while( c != EOF_MARK )
  50.     {  printf("  c=%d ",c) ;
  51.        c = get_next_char()    ;
  52.        i = i+1 ;
  53.        if( i > 100 )
  54.           break  ;
  55.     }
  56.  
  57.      printf("\n EOF reached - c=%d \n",c) ;
  58.      scanf("%c%c",&c,&c) ;      /* pause here  */
  59.  
  60.  
  61.  
  62.     move_to(filesize)  ;    /* start at end of file  */
  63.     printf("\n test get_next_char at eof \n") ;
  64.     for( i=0 ; i < 10 ; i=i =i+1 )
  65.        {  printf("  c=%d ",get_next_char() ) ; }
  66.     printf("\n thru \n") ;
  67.      scanf("%c%c",&c,&c) ;   /* pause here */
  68.  
  69.      /* test get previous char */
  70.      printf("\n test get_previous_char \n") ;
  71.      i = 0 ;
  72.      c = get_previous_char()  ;
  73.      while ( c != BOF_MARK )
  74.     { printf(" c=%d ",c) ;
  75.       c = get_previous_char() ;
  76.       i = i+1 ;
  77.       if( i > 100 )
  78.           break  ;
  79.     }
  80.      printf("\n BOF reached - c+%d \n",c) ;
  81.      scanf("%c%c ",&c,&c) ;     /* pause here  */
  82.  
  83.  
  84.     move_to(0L) ;
  85.     printf("\n test get_previous_char at BOF \n") ;
  86.     for( i=0 ; i < 10 ; i = i+1 )
  87.        {  printf("  c=%d ",getprevious_char() ) ;  }
  88.     printf("\n thru  \n") ;
  89.  
  90.      close_file()  ;
  91.   }
  92.  
  93.  
  94.  
  95.